# coding:utf8

def assert_status_code(response, expected_code):
    """
    参数化断言响应状态码是否符合预期。

    :param response: requests库的Response对象
    :param expected_code: 预期的状态码，整数类型
    """
    assert response and response.status_code == expected_code, f"预期状态码 {expected_code}，实际 {response.status_code if response else None}"


def assert_json_field(response, field):
    """
    参数化断言响应的JSON数据中是否包含指定字段。

    :param response: requests库的Response对象
    :param field: 要检查的字段，字符串类型
    """
    user_data = response.json() if response else {}
    assert field in user_data, f"响应JSON数据中不包含字段 {field}"